package org.richin.collection.util;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * Empty iterator that is used for <code>null</code> Lists.
 *
 * @param <T> the type over which to iterate.
 *
 * @author Copyright &copy; 2008
 * <a href="mailto:javelotinfo@users.sourceforge.net">Frederic Daoud</a>
 */
public class EmptyIterator<T> implements Iterator<T>
{
    /**
     * Returns <code>false</code>.
     */
    public boolean hasNext()
    {
        return false;
    }

    /**
     * Returns <code>null</code>.
     */
    public T next()
    {
        throw new NoSuchElementException("No elements in empty iterator");
    }

    /**
     * Throws a {@link java.lang.UnsupportedOperationException}.
     */
    public void remove()
    {
        throw new UnsupportedOperationException("No remove() in empty iterator");
    }
}
